package cut_stock_2;

import java.io.*;

public class DataReader {

    public int stockLength;
    public double[] specs;
    public double[] requirements;

    public void loadFile(String path) {
        try {
            FileReader fr = new FileReader(path);
            BufferedReader br = new BufferedReader(fr);
            String line;
            String[] temp;
            int i = 0;
            while ((line = br.readLine()) != null) {

                if (i == 0) {

                    stockLength = Integer.parseInt(line);

                } else if (i == 1) {

                    temp = line.substring(1, line.length() - 1).split(",");
                    specs = new double[temp.length];
                    for (int j = 0; j < temp.length; j++) {
                        specs[j] = Integer.valueOf(temp[j]);
                    }

                } else if (i == 2) {

                    temp = line.substring(1, line.length() - 1).split(",");
                    requirements = new double[temp.length];
                    for (int j = 0; j < temp.length; j++) {
                        requirements[j] = Double.parseDouble(temp[j]);
                    }

                }
                i++;

            }
            br.close();
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}